#!/usr/bin/env python3
"""
Simple test server for ArXiv Subscription Platform
Runs without database dependencies for testing
"""

import os
import sys
from pathlib import Path

# Add backend to Python path
backend_path = Path(__file__).parent / "backend"
sys.path.insert(0, str(backend_path))

try:
    import uvicorn
    from fastapi import FastAPI
    from fastapi.responses import JSONResponse
    
    app = FastAPI(title="ArXiv Subscription Platform - Test Mode")
    
    @app.get("/")
    async def root():
        return {"message": "ArXiv Subscription Platform - Test Mode", "status": "running"}
    
    @app.get("/health")
    async def health():
        return {"status": "healthy", "environment": os.getenv("ENVIRONMENT", "test")}
    
    @app.get("/api/test")
    async def test_api():
        return {"message": "API is working", "python_version": sys.version}
    
    if __name__ == "__main__":
        print("Starting ArXiv Subscription Platform test server...")
        print("Access the API at: http://localhost:8000")
        print("API docs at: http://localhost:8000/docs")
        print("Health check: http://localhost:8000/health")
        uvicorn.run(app, host="0.0.0.0", port=8000, reload=True)

except ImportError as e:
    print(f"Error importing dependencies: {e}")
    print("Please ensure all dependencies are installed")
    sys.exit(1)
